package com.android.rutaszalagarda;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.Button;

public class Home extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_home);
		
		final Animation animTranslate = AnimationUtils.loadAnimation(this, R.anim.anim_translate);
		final Animation animTranslateLeft = AnimationUtils.loadAnimation(this, R.anim.anim_translateleft);
		
		//Obtenemos una referencia a los controles de la interfaz
        final Button btnNuevaRuta = (Button)findViewById(R.id.BtnNuevaRuta);
        final Button btnBusqueda = (Button)findViewById(R.id.BtnBusqueda);
        final Button btnMisRutas = (Button)findViewById(R.id.BtnMisRutas);
        final Button btnEstadisticas = (Button)findViewById(R.id.BtnEstadisticas);
        final Button btnOpciones = (Button)findViewById(R.id.BtnOpciones);
        //final Button btnSalir = (Button)findViewById(R.id.BtnSalir);
        
        //NUEVA RUTA
        btnNuevaRuta.setOnClickListener(new OnClickListener() {
        	public void onClick(View v) {
        		//	Transiciones visuales
        		btnNuevaRuta.startAnimation(animTranslate);
        		
        		animTranslate.setAnimationListener(new AnimationListener() {
                    public void onAnimationStart(Animation anim){
                   	 
                    };
                    public void onAnimationRepeat(Animation anim){
                   	 
                    };
                    public void onAnimationEnd(Animation anim){
                    	Intent intent = new Intent(Home.this, NuevaRuta.class); 
                		startActivity(intent);
                    };
                });           		
        	}
        });
        
      //BUSQUEDA
      btnBusqueda.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
            	btnBusqueda.startAnimation(animTranslate);
            	animTranslate.setAnimationListener(new AnimationListener() {
                    public void onAnimationStart(Animation anim){
                   	 
                    };
                    public void onAnimationRepeat(Animation anim){
                   	 
                    };
                    public void onAnimationEnd(Animation anim){
                    	Intent intent = new Intent(Home.this, Busqueda.class); 
                		startActivity(intent);
                    };
                });    
            }
       });
      
       //MIS RUTAS
       btnMisRutas.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
            	btnMisRutas.startAnimation(animTranslate);
            	animTranslate.setAnimationListener(new AnimationListener() {
                    public void onAnimationStart(Animation anim){
                   	 
                    };
                    public void onAnimationRepeat(Animation anim){
                   	 
                    };
                    public void onAnimationEnd(Animation anim){
                    	Intent intent = new Intent(Home.this, MisRutas.class); 
                		startActivity(intent);
                    };
                });
            }
       });
       
       //ESTADISTICAS
       btnEstadisticas.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
            	btnEstadisticas.startAnimation(animTranslate);
            	animTranslate.setAnimationListener(new AnimationListener() {
                    public void onAnimationStart(Animation anim){
                   	 
                    };
                    public void onAnimationRepeat(Animation anim){
                   	 
                    };
                    public void onAnimationEnd(Animation anim){
                    	Intent intent = new Intent(Home.this, Estadisticas.class); 
                		startActivity(intent);
                    };
                });
            }
       });
       
       //OPCIONES
       btnOpciones.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
            	btnOpciones.startAnimation(animTranslateLeft);
            	animTranslateLeft.setAnimationListener(new AnimationListener() {
                    public void onAnimationStart(Animation anim){
                   	 
                    };
                    public void onAnimationRepeat(Animation anim){
                   	 
                    };
                    public void onAnimationEnd(Animation anim){
                    	Intent intent = new Intent(Home.this, Opciones.class); 
                		startActivity(intent);
                    };
                });
            }
       });
	}
}
